<template>
	<view class="content">
		<view class="erweima">
			<image
				:src="data"
					
				@click="saveImage"
			></image>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			uid: '',
			data: ''
		};
	},
	methods: {
		async get() {
			const res = await this.$u.post('api/users/user_pay_code', {
				uid: this.uid
			});
			this.data = res.data;
		},
		// 保存图片
		saveImage(e) {
			wx.previewImage({
			  current: this.data, // 当前显示图片的http链接
			  urls: [this.data] // 需要预览的图片http链接列表
			})
		}
	},
	onLoad() {
		try {
			const uid = uni.getStorageSync('uid');
			if (uid) {
				this.uid = uid;
			}
		} catch (e) {
			// error
		}
		this.get();
	}
};
</script>

<style lang="scss">
.content {
	.erweima {
		position: absolute;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);
		width: 270rpx;
		height: 270rpx;
		// background-color: #1cbbb4;
		image {
			width: 100%;
			height: 100%;
		}
	}
}
</style>
